//
//  AlbumDetailViewController.m
//  PSYWeiBo
//
//  Created by xiaotian on 16/3/16.
//  Copyright © 2016年 郑亚田. All rights reserved.
//

#import "AlbumDetailViewController.h"
#import "AlbumDetaiHeadView.h"
#import "PhotoColCell.h"

@interface AlbumDetailViewController ()<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>

@property (nonatomic,strong)UICollectionView *photoCol;

@end
@implementation AlbumDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleLab.text = @"相册详情";
    
    [self setViews];
}

- (void)setViews {
    AlbumDetaiHeadView *albumV = [[AlbumDetaiHeadView alloc] init];
    [self.view addSubview:albumV];
    [albumV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headerImgV.mas_bottom).with.offset(-10);
        make.left.right.equalTo(@0);
        make.height.equalTo(@(kScreenHeight * 0.32));
    }];
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    flowLayout.itemSize = CGSizeMake(kScreenWidth, kScreenHeight - albumV.bounds.size.height);
    flowLayout.minimumInteritemSpacing = kScreenWidth/15;
    flowLayout.sectionInset = UIEdgeInsetsMake(kScreenWidth/25, kScreenWidth/20, kScreenWidth/25, kScreenWidth/20);
    
    self.photoCol = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) collectionViewLayout:flowLayout];
    [self.view addSubview:self.photoCol];
    [self.photoCol mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(albumV.mas_bottom);
        make.left.right.bottom.equalTo(@0);
    }];

    self.photoCol.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1.0];
    self.photoCol.pagingEnabled = YES;
    self.photoCol.delegate = self;
    self.photoCol.dataSource = self;
    [self.photoCol registerClass:[PhotoColCell class] forCellWithReuseIdentifier:@"photoCell"];
}

#pragma mark - collectionview代理方法
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    PhotoColCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"photoCell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor lightGrayColor];
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:      (NSIndexPath *)indexPath {
    return CGSizeMake(kScreenWidth/4, kScreenWidth/4);
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
